﻿@if (Request.IsAuthenticated)
{
    <text>
        <a href="#" data-toggle="dropdown" class="dropdown-toggle">
            <div class="auth">
                <img class="profile-img" src=""/>
                Howdy, <span class="username"></span> <b class="caret"></b>
            </div>
        </a>
        <ul class="dropdown-menu">
            <li><a href="/User/Id/@WebSecurity.CurrentUserId">Personal Page</a></li>
            @if (User.IsInRole(Capstone_20130302.Constants.Constant.ROLE_ADMIN))
            {
                <li><a href="/Admin/ManageStore">Administration</a></li>
            }
            @if (User.IsInRole(Capstone_20130302.Constants.Constant.ROLE_BUYER))
            {
                <li><a href="/Account/Upgrade">Upgrade to Business Account</a></li>
            }
            @if (User.IsInRole(Capstone_20130302.Constants.Constant.ROLE_SELLER))
            {
                <li><a href="/Store">My Stores</a></li>
            }
            <li class="divider"></li>
            <li>@Html.ActionLink("User Setting", "Manage", "Account")</li>
            <li><a href="javascript:document.getElementById('logoutForm').submit()">Log Out</a></li>
        </ul>

        @using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm" }))
        {
            @Html.AntiForgeryToken()
            
        }
        <script>
            var displayName = "";
            $(document).ready(function () {
                $.getJSON("/Account/GetUserProfile?UserId=@WebSecurity.CurrentUserId", function (data) {
                    $(".profile-img").attr("src", "/Image/"+data.ProfileImage.ImageId);
                    $("span.username").text(data.DisplayName);
                    displayName = data.DisplayName;
                });
            });
        </script>
    </text>
}
else
{
    <ul class="right-menu">
        <li>@Html.ActionLink("Register", "Register", "Account")</li>
        <li>@Html.ActionLink("Login", "Login", "Account")</li>
        @*<li><a href="#register-modal" role="button" data-toggle="modal">Register</a></li>
        <li><a href="#login-modal" role="button" data-toggle="modal">Log in</a></li>*@
    </ul>
    @*
    @Html.Partial("_LoginModal", new Capstone_20130302.Models.LoginModel())
    @Html.Partial("_RegisterModal", new Capstone_20130302.Models.RegisterModel())*@
}
